/// <reference path="../Dependencies/QUnit/qunit.d.ts" />
/// <reference path="../Math/Vector2.ts" />

class MathTests{

    public static run(): void {
        QUnit.test("vector2", vector2Test);
    }

    public static vector2Test(): void {
        var Vector2 = ew.Vector2;
        QUnit.equal(Vector2.unitX.getLength(), 1, "length of unitX vector");
        QUnit.equal(Vector2.unitY.getLength(), 1, "length of unitY vector");
        QUnit.equal(Vector2.unit.getLength(), Math.SQRT2, "length of unit vector");

        var vec = new Vector2(15, 13);
        QUnit.equal(vec.normalize().getLength(), 1, "normalize not normalizing");
        vec = new Vector2(15, 0);
        QUnit.equal(vec.getLengthSquared(), 15 * 15, "length squared");
        QUnit.equal(vec.dot(vec), vec.getLengthSquared(), "a^2 != a.length^2");

        var vec1 = new Vector2(10, 15);
        var vec2 = new Vector2(5, 17);
        QUnit.deepEqual(vec1.add(vec2), new Vector2(15, 32), "add");
        QUnit.deepEqual(vec1.substract(vec2), new Vector2(5, -2), "substract");
        QUnit.deepEqual(vec1.multiply(7), new Vector2(70, 105), "multiply");
        QUnit.deepEqual(vec1.divide(10), new Vector2(1, 1.5), "divide");
        QUnit.deepEqual(vec1.negate(), new Vector2(-10, -15), "negate");
    }
}